/**
 * Created by Administrator on 2018/10/28.
 */
$(function () {
    var $account = $('#login-account');
    var $password = $('#login-password');
    var $loginSub = $('#login-sub');
    $loginSub.on('click', function () {
        var account = $account.val();
        var password = $password.val();
        if (!account) {
            _alert('请输入手机号或账号');
            return;
        }
        if (!password) {
            _alert('请输入密码');
            return;
        }
        console.log(hex_md5(password));
        ajax({
            url: 'app/user/login',
            data: {
                account: account,
                password: password
            },
            success: function (d) {
                _alert('登录成功');
                setUserInfo({
                    userId: d.id,
                    token: d.token
                });
                console.log(getToken(), getUserId());
                window.location.href = 'home.html';
            },
            fail: function (d) {
                _alert(d.message.msg || '登录失败');
            }
        })
    });
});